<?php

/**
 * Platcode functions
 */

/**
 * Fetch Platcode event manager
 * @return Event_Manager
 */
function &platcode() {
	return Event_Manager::$instance;
}

/**
 * Fetch database connection
 * @return PDO
 */
function &database() {
	return platcode()->plugins->import('Database')->dataobject;
}

/**
 * Language item
 * @param string $name
 * @return string
 */
function lang($name) {
	return platcode()->lang->$name;
}

/**
 * Configuration item
 * @param string $name
 * @return mixed
 */
function config($name) {
	return platcode()->config->$name;
}

/**
 * Include a service
 * @param string $classpath
 * @return boolean
 */
function include_service($classpath) {
	return platcode()->plugins->include_class('service/'.$classpath);
}

/**
 * Validate a user session
 * @return boolean
 */
function is_user_session() {
	return platcode()->plugins->import('Session')->validate_client('generate_user_session');
}

// end of file